<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Kafka日志收集</title>
    <script type="text/javascript" src="js/jquery-3.6.0.js"></script>
    <script type="text/javascript" src="js/lagou.js"></script>
</head>
<body>

    <button id="click" class="action" act_type="click">点击</button>
    <button id="collect" class="action" act_type="favorite">收藏</button>
    <button id="send" class="action" act_type="sendCV">投简历</button>
    <button id="upload" class="action" act_type="uploadCV">上传简历</button>

</body>

<script>
    $(document).ready(function () {
        $(".action").click(function () {
            var user_id = $("#user_id").val()+formatNewDate();
            var act_time = new Date();
            var action = this.getAttribute("act_type")
            var job_code = $("#job_code").val()+formatNewDate();
            var log = "user_id:"+user_id + "\t" +"act_time:"+act_time + "\t" +"action:"+ action + "\t" +"job_code:"+job_code;
            $.ajax({
                url: "http://centos7-1/log",
                type: "POST",
                dataType: "json",
                data: log
            })
        });
    })
    function add0(m){return m<10?'0'+m:m }
    function formatNewDate(){
        //shijianchuo是整数，否则要parseInt转换
        var time = new Date();
        var y = time.getFullYear();
        var m = time.getMonth()+1;
        var d = time.getDate();
        var h = time.getHours();
        var mm = time.getMinutes();
        var s = time.getSeconds();
        return y+'-'+add0(m)+'_'+add0(d)+'_'+add0(h)+'_'+add0(mm)+'_'+add0(s);
    }
</script>

</html>